var t = getApp();

Page({
    data: {
        nickname: "",
        transferID: "",
        transferIntegral: "",
        integral: 0,
        name: "",
        isclick: !0
    },
    onLoad: function(t) {
        this.getName(), this.getData();
    },
    onReady: function() {},
    onShow: function() {
        this.data.isclick = !0;
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    onChange: function(t) {
        var a = this;
        if (!/^[\+\-]?\d*?\.?\d*?$/.test(t.detail)) return wx.showToast({
            title: "只能输入数字",
            icon: "none"
        }), void this.setData({
            recharge_id: ""
        });
        this.setData({
            transferID: t.detail
        }), this.data.timerId && clearTimeout(this.data.timerId), this.data.timerId = setTimeout(function() {
            a.getNickName();
        }, 800);
    },
    getNickName: function() {
        var a = this;
        if (this.data.transferID) {
            var e = t.getNetAddresss("member.member.memberInfo");
            t._getNetWork({
                url: e,
                data: {
                    uid: this.data.transferID
                },
                success: function(t) {
                    1 === t.data.result ? a.setData({
                        nickname: t.data.data.nickname
                    }) : a.setData({
                        nickname: ""
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    onChange1: function(t) {
        if (console.log(t.detail, "值"), !/^[\+\-]?\d*?\.?\d*?$/.test(t.detail)) return wx.showToast({
            title: "只能输入数字",
            icon: "none"
        }), void this.setData({
            transferIntegral: ""
        });
        this.setData({
            transferIntegral: t.detail
        });
    },
    onChange2: function(t) {
        this.setData({
            recharge_value: t.detail
        });
        var a = this.data.recharge_value - this.data.recharge_value * (this.data.ratio / 100);
        a = a.toString(), this.setData({
            arrival_count: a.replace(/([0-9]+.[0-9]{2})[0-9]*/, "$1")
        });
    },
    getName: function() {
        var a = this, e = t.getNetAddresss("plugin.integral.Frontend.Controllers.page.get-name");
        t._getNetWork({
            url: e,
            success: function(t) {
                1 === t.data.result ? a.setData({
                    name: t.data.data
                }) : wx.showToast({
                    title: t.data.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.integral.Frontend.Controllers.Page.index");
        t._getNetWork({
            url: e,
            success: function(t) {
                1 === t.data.result ? (console.log(t.data.data.member_integral, "数据的强"), a.setData({
                    transferID: "",
                    transferIntegral: "",
                    integral: t.data.data.member_integral
                })) : wx.showToast({
                    title: t.data.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    sureTransfer: function() {
        var a = this;
        if (this.data.isclick) {
            if (this.data.isclick = !1, !this.data.transferIntegral) return wx.showToast({
                title: "请输入转让数额",
                icon: "none"
            }), void (this.data.isclick = !0);
            if (Number(this.data.transferIntegral) > Number(this.data.integral)) return wx.showToast({
                title: "输入的提现数额超过已有的" + this.data.name,
                icon: "none"
            }), void (this.data.isclick = !0);
            var e = t.getNetAddresss("plugin.integral.Frontend.Modules.Integral.Controllers.Transfer");
            e += "&change_value=" + this.data.transferIntegral, e += "&recipient_id=" + this.data.transferID, 
            t._getNetWork({
                url: e,
                success: function(t) {
                    1 === t.data.result ? (a.getData(), wx.showToast({
                        title: "转让成功",
                        icon: "none"
                    }), setTimeout(function() {
                        wx.navigateTo({
                            url: "/packageB/member/Integral_love_detail/Integral_love_detail"
                        });
                    }, 1e3)) : (a.data.isclick = !0, wx.showToast({
                        title: t.data.msg,
                        icon: "none"
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else wx.showToast({
            title: "请勿重复点击",
            icon: "none"
        });
    }
});